package org.aplombh.java.interview.newcoder;

import java.util.Scanner;

//HJ20 密码验证合格程序
public class HJ20_密码验证合格程序 {
    public static void main(String[] args) {
        Scanner in = new Scanner(System.in);
        while (in.hasNext()) {
            String a = in.nextLine();
            System.out.println(check(a));
        }
    }

    private static String check(String a) {
        if (a.length() < 8) return "NG";
        int f1 = 0, f2 = 0, f3 = 0, f4 = 0;

        for (int i = 0; i < a.length(); i++) {
            if (a.charAt(i) <= 'Z' && a.charAt(i) >= 'A') {
                f1 = 1;
            } else if (a.charAt(i) <= 'z' && a.charAt(i) >= 'a') {
                f2 = 1;
            } else if (a.charAt(i) <= '9' && a.charAt(i) >= '0') {
                f3 = 1;
            } else {
                f4 = 1;
            }
        }

        if (!(f1 + f2 + f3 + f4 >= 3)) return "NG";

        boolean b1 = true;
        for (int i = 0; i < a.length() - 2; i++) {
            String subString = a.substring(i, i + 3);
            for (int j = i + 3; j < a.length() - 2; j++) {
                if (a.charAt(j) == subString.charAt(0) && a.charAt(j + 1) == subString.charAt(1) && a.charAt(j + 2) == subString.charAt(2)) {
                    b1 = false;
                    break;
                }
            }
        }
        if (!b1) return "NG";

        return "OK";
    }
}